package com.yywq.error;

/**
 * @author: 吴磊
 * @program: yywq
 * @create: 2021-03-18 18:46
 */


/**
 * 枚举类的异常类，主要是用来统一错误码
 *
 * @author 29216
 */
public enum EnumBusinessError implements CommonError {
    //通用的错误类型 10001
    PARAMETER_INVALID_ERROR(10001, "参数不合法"),
    UNKNOWN_ERROR(10002, "未知错误"),

    //20000 开头为用户信息相关错误定义
    USER_NOT_EXIST(20001, "用户不存在"),
    USER_IS_EXIST(20002, "手机号已注册"),

    USER_LOGIN_FAIL(20003, "用户手机号或密码不正确"),
    USER_NOT_LOGIN(20004, "用户还未登录"),
    //30000开头商品业务逻辑错误
    STOCK_NOT_ENOUGH(30001, "库存不足"),
    GOODS_NOT_EXIST(30001, "商品不存在或者库存不足");


    private int errorCode;

    private String errorMsg;

    EnumBusinessError(int errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }


    @Override
    public int getErrorCode() {
        return this.errorCode;
    }

    @Override
    public String getErrorMsg() {
        return this.errorMsg;
    }

    @Override
    public CommonError setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
        return this;
    }
}
